{extends file="./main.tpl"}
{block name=head}
<script type="text/javascript">
$(document).ready(function() {
	$(".add").blur(function()
	{
	  if($(".add:last").val() != '' && $(".add:last").val() > 0)
	  {
      $("#one").clone(true).appendTo("#mainDiv")
      .find('input[type="text"]').val('').end()
      .find('select[option=""]').val('');
    }
    $('.amount:Last').val(0);
  });
});
function setTotalWeight()
{
  var totalWeight  = 0;
  
  $('.weight').each(function(i)
  {
    weight = $(this).val().replace("$","");
    if(!isNaN(weight))
    {
    	totalWeight += Number(weight);
    	$('#totalWeight').val(totalWeight.toFixed(0));
    }
  }); 
}

function setTotalAmount()
{
  var totalAmount = 0;
  
  $('.amount').each(function(i)
  {
    amount = $(this).val();
    if(!isNaN(amount))
    {
    	totalAmount += Number(amount);
    	$('#totalAmount').val(totalAmount);
    }
  }); 
}

function myFunction()
{
  if(confirm("You Want To Remove This Record")== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}
</script>
{/block}
{block name=body}
<form name="driver" action="{$smarty.server.PHP_SELF}" method="post" onsubmit="submitBtn(this)">  
<input type="hidden" name="loaddingId" value="{$loadinginvoiceId}">
<table align="center" border="2" cellpadding="2" cellspacing="2" width="" >
<tr>
  <td align="center" class="table1" colspan="16"><h3>Loading Invoice</h3></td>
</tr>
<tr>
  <td align="center" class="table2">FROM :</td>
  <td align="center" class="table2">
    <input type="text" value="{$branchNameSelected}" READONLY >
    <input type="hidden" name="branchIdSelected" value="{$branchIdSelected}" >
  </td>
  <td align="right" class="table2">TO :</td>
  <td align="left" class="table2" nowrap><b>{$lodingRow.branchName}</b></td>
  <td align="right" class="table2">Truck No : </td>
  <td align="left" class="table2"><b>{$lodingRow.truckNo}</b></td>
  <td align="right" class="table2">Invoice No :</td>
  <td align="left" class="table2"><b>{$lodingRow.invoiceNo}</b></td>
  <td align="right" class="table2" colspan="2">Invoice Date :</td>
  <td align="left" class="table2"><b>{$lodingRow.invoiceDate|date_format:"%e-%m-%Y"}</b></td>
</tr>
<tbody  id="mainDiv">
<tr>
	<td class="table2"  align="center">&nbsp;</td>
	<td class="table2"  align="center">LR no.</td>
	<td class="table2"  align="center">LR Date.</td>
	<td class="table2"  align="center">Article / Qty</td>
	<td class="table2"  align="center">Description</td>
	<td class="table2"  align="center">Consignor</td>
	<td class="table2"  align="center">Consignee</td>
	<td class="table2"  align="center">Weight</td>
	<td class="table2"  align="center">To pay/ paid</td>
	<td class="table2"  align="center">Amount</td>
	<td class="table2"  align="center">Remarks</td>
</tr>
<tr id="one">
	 <td class="table2">
  	<select name="billType[]" autofocus />
  	  {html_options values=$printValueArray output=$printOutputArray}
    </Select>
  </td>
	<td class="table2" align="center"><input type="text" name="lrNo[]" class="add" size="4"></td>
	<td class="table2" align="center" NoWRAP>
		{html_select_date field_array="lrDate[]" prefix="" start_year ="-0" end_year="+2" field_order ="DMY" month_format="%m" day_value_format="%02d"}</td>
	<td class="table2" align="center"><input type="text" name="qty[]" size="4"></td>
	<td class="table2" align="center">
    <select name="discriptionPartyDetailId[]" id="combo" >
    <option value="0">select</option>
      {html_options values=$itemArray.partyDetailId output=$itemArray.item}
    </select>
	  <input type="text" name="discription[]" id="tb">
	</td>
	<td class="table2" align="center">
    <select name="consignorPartyId[]">
    <option value="0">select</option>
      {html_options values=$PartyArray.partyId output=$PartyArray.name}
    </select>	
		<input type="text" name="consignor[]" >
	</td>
	<td class="table2" align="center"><input type="text" name="consignee[]" ></td>
	<td class="table2" align="center"><input type="text" name="weight[]" size="4" class="weight" onblur="setTotalWeight();"></td>
	<td class="table2" align="center">
	  <select name="toPay[]">
	    {html_options values=$topayValueArray output=$topayOutputArray}
	  <select>
  </td>
	<td class="table2" align="center"><input type="text" name="amount" class="amount" name="amount[]" onblur="setTotalAmount();" size="4" value="0"></td>
	<td class="table2" align="center"><textarea   name="remarks[]" cols="10" rows="2"></textarea></td>
</tr>
</tbody>
<tr>
  <td colspan="7" class="table2">&nbsp;</td>
  <td class="table2" align="center"><input type="text" id="totalWeight" name="totalWeight"></td>
  <td colspan="1" class="table2">&nbsp;</td>
  <td class="table2" align="center"><input type="text" id="totalAmount" name="totalAmount"></td>
</tr>
<tr>
  <td class="table1" align="center" colspan="12"><input type="submit" name="submit" value="Submit" class="button"></td> 
</tr>
</table>
<br><br>
</form>
{/block}
